﻿/*****************************************
 * File Name:   RequestLoader.js
 * Author:      Chen Xin
 * Version:     1.0
 * Date:        2006-09-19
 * Description: 页面请求函数集
 *****************************************/

var RequestLoader = new Object();

RequestLoader.showLegend = function() {
    var page = "Legend.aspx";
    var params = "XMIN=" + m_mapViewer.getExtent().getLeft() + 
                "&YMIN=" + m_mapViewer.getExtent().getTop() + 
                "&XMAX=" + m_mapViewer.getExtent().getRight() + 
                "&YMAX=" + m_mapViewer.getExtent().getBottom() + 
                "&WIDTH=" + m_mapViewer.getTagWidth() + 
                "&HEIGHT=" + m_mapViewer.getTagHeight();
    var loader = new Net.ContentLoader(page, openLegend, null, "POST", params, null);
    m_imgMapCanvas.style.cursor = "default";
}

RequestLoader.showPlanterInfo = function() {

	// Get event coordinates by browser-specific means.
	var evt = evt || window.event;
	
	var eventX;
	var eventY;
	
	eventX = mouseCoords(evt).x;
	eventY = mouseCoords(evt).y;
	
	var xmin;
	var xmax;
	var ymin;
	var ymax;
	//var xcenter;
	//var ycenter;
	var pointMouse = m_mapViewer.toMapPoint(eventX, eventY);
	var pointLeftBottom = m_mapViewer.toMapPoint(eventX - 3, eventY + 3);
	var pointRightTop = m_mapViewer.toMapPoint(eventX + 3, eventY - 3);
    xmin = pointLeftBottom.x;
    xmax = pointRightTop.x;
    ymin = pointLeftBottom.y;
    ymax = pointRightTop.y;
	
	
//	xmin = m_txtXCoord.value.substring(3);
//	ymax = m_txtYCoord.value.substring(3);
//	xmax = new Number(xmin) + 0.001;
//	ymin = new Number(ymax) - 0.001;
	
	var params = "XMIN=" + xmin +
	            "&YMIN=" + ymin +
	            "&XMAX=" + xmax +
	            "&YMAX=" + ymax +
	            "&eventX=" + eventX +
	            "&eventY=" + eventY;
	
    var page = "PlanterIdentify.aspx";
    var loader = new Ajax.Request(page, {method: 'post', parameters: params, onComplete: openPlanterInfo});
}